import React from 'react';
import {
    View,
    Text,
    Navigator,
    TouchableOpacity,
    DrawerLayoutAndroid
} from 'react-native';

import SecondPageComponent from '../secondComponent/SecondPageComponent';

export default class ThirdPageComponent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
          fist:1
        };
    }
    componentDidMount() {
      // alert(this.props.name);

    }
    childMethod() {
      const { navigator } = this.props;
      //为什么这里可以取得 props.navigator?请看上文:
      //<Component {...route.params} navigator={navigator} />
      //这里传递了navigator作为props
      if(navigator) {
          navigator.push({
              name: 'SecondPageComponent',
              component: SecondPageComponent,
          })
      }
    }
    _pressButton() {
        const { navigator } = this.props;
        //为什么这里可以取得 props.navigator?请看上文:
        //<Component {...route.params} navigator={navigator} />
        //这里传递了navigator作为props
        if(navigator) {
            navigator.push({
                name: 'SecondPageComponent',
                component: SecondPageComponent,
            })
        }
    }
    render() {
        let { position } = this.props;
        var navigationView = (
          <View style={{flex: 1, backgroundColor: '#fff'}}>
            <Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>I'm in the Drawer!</Text>
          </View>
        );
        return (
          <DrawerLayoutAndroid
            drawerWidth={300}
            drawerPosition={DrawerLayoutAndroid.positions.Left}
            renderNavigationView={() => navigationView}>
            <View style={{flex: 1, alignItems: 'center'}}>
              <Text style={{margin: 10, fontSize: 15}}>试试左滑</Text>
            </View>
          </DrawerLayoutAndroid>
        );
    }
}
